/**
 * Created by vicket on 2017/4/4.
 */
$(function(){

   //��������ĺ���
    function ajax(obj){
        $.ajax({
            type:'get',
            url:obj.url,
            success:function(result){
                obj.fn(result);
            }
        })
    }
    //�ֲ�ͼ
    var wrapper=$(".swiper-wrapper");
    //�ֲ��ص�
    function carouselfn(result){
        var html=template("carousel",{"items":result});
        wrapper.html(html);
        var mySwiper = new Swiper ('.swiper-container', {
            loop: true,
            autoplay : 2000,
            // �����Ҫ��ҳ��
            pagination: '.swiper-pagination',
        });
    }
    var carouselObj={url:'/api/frontGetIndexLunbo',fn:carouselfn}
    ajax(carouselObj);

    //С���Ƽ�
    var editList=$(".edit_list");
    function editfn(result){
       var html=template("edit",{"items":result});
       editList.html(html);
   }
    var carouselObj={url:'/api/frontGetRecommend',fn:editfn}
    ajax(carouselObj);
    //�����Ƽ�
    var newList=$(".new_list");
    function newfn(result){
        var html=template("newbook",{"items":result});
        newList.html(html);
    }
    var newObj={url:'/api/frontGetNewProduct',fn:newfn}
    ajax(newObj);

    //����Ƽ�
    var finishList=$(".finish_list");
    function finishfn(result){
        var html=template("finishbook",{"items":result});
        finishList.html(html);
    }
    var finishObj={url:'/api/frontGetEndProduct',fn:finishfn}
    ajax(finishObj);

    //�ղ��Ƽ�
    var storeList=$(".store_list");
    function storefn(result){
        var html=template("storebook",{"items":result});
        storeList.html(html);
    }
    var storeObj={url:'/api/frontGetCollectionProduct',fn:storefn}
    ajax(storeObj);

})